package com.mdd.admin.controller.googs;

import com.mdd.admin.config.aop.Log;
import com.mdd.admin.service.googs.ISalesmanGoogsService;
import com.mdd.admin.validate.common.PageParam;
import com.mdd.admin.validate.googs.SalesmanGoogsParam;
import com.mdd.admin.vo.goods.GoodsDetailVo;
import com.mdd.admin.vo.googs.SalesmanGoogsDetailVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.entity.goods.Goods;
import com.mdd.common.validator.annotation.IDMust;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 推销员服务管理
 */
@RestController
@RequestMapping("api/googs")
public class SalesmanGoogsController {

    @Resource
    ISalesmanGoogsService iSalesmanGoogsService;

    /**
     * 推销员服务列表
     *
     * @param pageParam 分页参数
     * @param params 搜索参数
     * @return Object
     */
    @GetMapping("/list")
    public PageResult<SalesmanGoogsDetailVo> list(@Validated PageParam pageParam,
                                          @RequestParam Map<String, String> params) {
        return iSalesmanGoogsService.list(pageParam, params);
    }
    /**
     * 推销员服务详情
     *
     * @param id 主键ID
     * @return Object
     */
    @GetMapping("/detail")
    public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        SalesmanGoogsDetailVo detail = iSalesmanGoogsService.detail(id);
        return AjaxResult.success(detail);
    }

    /**
     * 推销员服务新增
     *
     * @param salesmanGoogsParam 参数
     * @return Object
     */
    @Log(title = "推销员服务新增")
    @PostMapping("/add")
    public Object add(@Validated(value = SalesmanGoogsParam.create.class) @RequestBody SalesmanGoogsParam salesmanGoogsParam) {
        iSalesmanGoogsService.add(salesmanGoogsParam);
        return AjaxResult.success();
    }

    /**
     * 推销员服务编辑
     *
     * @param salesmanGoogsParam 参数
     * @return Object
     */
    @Log(title = "推销员服务编辑")
    @PostMapping("/edit")
    public Object edit(@Validated(value = SalesmanGoogsParam.update.class) @RequestBody SalesmanGoogsParam salesmanGoogsParam) {
        iSalesmanGoogsService.edit(salesmanGoogsParam);
        return AjaxResult.success();
    }

    @GetMapping("/del")
    public Object del(@Validated @IDMust() @RequestParam("id") Integer id) {
        iSalesmanGoogsService.del(id);
        return AjaxResult.success();
    }
}
